package com.example.medical.controller.user;

import com.example.medical.entity.dto.UserGetDeviceListDto;
import com.example.medical.service.DeviceService;
import com.example.medical.utils.common.enums.Code;
import com.example.medical.utils.common.result.Result;
import com.example.medical.utils.config.BaseContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/device")
public class UserDeviceController {

    @Autowired
    private DeviceService deviceService;

    @PostMapping("/get_device_list")
    public Result UserGetDeviceList(@RequestBody UserGetDeviceListDto dto){
        return deviceService.UserGetDeviceList(dto);
    }

    @GetMapping("/get_device_detail")
    public Result UserGetDeviceDetail(@RequestParam("id")Long id){
        if (BaseContext.getCurrentId()==null) {
            return Result.errorResult(Code.NEED_LOGIN);
        }
        return Result.okResult(deviceService.getById(id));
    }

}
